function out = f_ANN_training_testing_diff(ALL_vectors_training,All_testing)

% s1=size(ALL_vectors_training{1},2)
% s2=length(ALL_vectors_training)
% hiddenlayers = floor((s1+s2)/2)
hiddenlayers = 15;
N_class = length(ALL_vectors_training);

%========
Xall = [];
for i=1:N_class
    for k=1:size(ALL_vectors_training{i},1)
%         k
        Xall=[
            Xall
            ALL_vectors_training{i}(k,:) ];
    end
end
grand_avg = mean(Xall);    
for i=1:N_class
    ALL_vectors_training{i}=ALL_vectors_training{i}-grand_avg;  
%     ALL_vectors_training{i}=zscore(ALL_vectors_training{i});     
end
%==========
Xall = [];
for i=1:N_class
    for k=1:size(All_testing{i},1)
        Xall=[
            Xall
            All_testing{i}(k,:) ];
    end
end
grand_avg = mean(Xall);    
for i=1:N_class
    All_testing{i}=All_testing{i}-grand_avg;    
end

X_features=[]; Y=[];
for iclass = 1:N_class
    y_label = [];
    tar=zeros(1,N_class);
    tar(1,iclass)=1;
    for i=1:size(ALL_vectors_training{iclass},1)
        y_label(i,:)=tar;
    end
    Y =[Y
        y_label];
    X_features = [X_features;ALL_vectors_training{iclass}];
end
pause(0.1)
X_tr = X_features';y_tr = Y';
clear y_label;


%===========
X_features=[]; Y=[];
for iclass = 1:N_class
    y_label = [];
    tar=zeros(1,N_class);
    tar(1,iclass)=1;
    for i=1:size(All_testing{iclass},1)
        y_label(i,:)=tar;
    end
    Y =[Y
        y_label];
    X_features = [X_features;All_testing{iclass}];
end
pause(0.1)
X_test = X_features';y_test = Y';

%===========
'before'
pause(0.1)
model = fitnet(hiddenlayers,'trainbr');
model.trainParam.epochs = 100;
model.trainParam.showWindow = false;
pause(0.2)
size(X_tr)
size(y_tr)
[model tr] = train(model, X_tr,y_tr);
'trained'


pred = model(X_test);
'done'
[c,CM] = confusion(y_test,pred);
out.CM = CM;
out.PC = sum(diag(CM))./sum(sum(CM))
